*** Figures 3 and 4

clear

use "${data}cleaned_data_y3.dta", clear

do "${blocks}construct_new_variables"

drop if ApplyYear>=2017

gen GenderPool_ad = ""
replace GenderPool_ad = "Pooled female" if Gender == "Female" & WinterPool == 1
replace GenderPool_ad = "Direct male" if Gender == "Male" & WinterPool == 0
replace GenderPool_ad = "Direct female" if Gender == "Female" & WinterPool == 0
replace GenderPool_ad = "Pooled male" if Gender == "Male" & WinterPool == 1

encode GenderPool_ad, gen(GenderPool)

gen SchoolPool_ad = ""
replace SchoolPool_ad = "Pooled state-funded" if SchoolType=="Maintained" & DomicileCat=="Home" & WinterPool == 1
replace SchoolPool_ad = "Direct privately-funded" if SchoolType=="Independent" & DomicileCat=="Home" & WinterPool==0
replace SchoolPool_ad = "Direct state-funded" if SchoolType=="Maintained" & DomicileCat=="Home"& WinterPool == 0
replace SchoolPool_ad = "Pooled privately-funded" if SchoolType=="Independent" & DomicileCat=="Home" & WinterPool==1

encode SchoolPool_ad, gen(SchoolPool)

********************************************************************************

**** 								GENDER GRAPHS BY SUBJECT GROUP (Figure 3)

********************************************************************************

distplot ns_std_perc_y1 if inrange(ns_std_perc_y1, -3, 3) & EEMP == 1, over(GenderPool) xlabel(-3(1)3, format(%9.0f)) ytitle("") xtitle("Standardized percentage score") subtitle("A: Math intensive (MI) subjects") graphregion(fc(white)) ///
lc(black black black black) lp(solid shortdash longdash_dot_dot shortdash_dot_dot ) lwidth(medthick medthick medthick medthick) aspectratio(0.8) legend(span) saving("${temp}estem.gph", replace) 


distplot ns_std_perc_y1 if inrange(ns_std_perc_y1, -3, 3) & EEMP == 0, over(GenderPool) xlabel(-3(1)3, format(%9.0f)) ytitle("") xtitle("Standardized percentage score") subtitle("B: Non-MI subjects") graphregion(fc(white)) ///
lc(black black black black) lp(solid shortdash longdash_dot_dot shortdash_dot_dot ) lwidth(medthick medthick medthick medthick)  aspectratio(0.8) legend(span) saving("${temp}non-estem.gph", replace) 

grc1leg2 "${temp}estem.gph" "${temp}non-estem.gph", graphregion(margin(t=10 b=10) fc(white)) r(1) iscale(0.7)

graph export "${graphs}figure3.eps" as(pdf), replace 

********************************************************************************

**** 								SCHOOL GRAPH (Figure 4)

********************************************************************************

distplot ns_std_perc_y1 if inrange(ns_std_perc_y1, -3, 3), over(SchoolPool) xlabel(-3(1)3, format(%9.0f)) ytitle("") xtitle("Standardized percentage score") subtitle("All subjects", span) graphregion(fc(white)) lc(black black black black)  lp(shortdash solid  shortdash_dot_dot longdash_dot_dot ) lwidth(medthick medthick medthick medthick) saving("${temp}school.gph", replace) aspectratio(0.8) legend(span)

graph export "${graphs}figure4.eps", replace  


*as(pdf) 
